package cn.liujianbo.example.base.selenium.demo;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

import java.util.concurrent.TimeUnit;

/**
 * @author 刘建波
 * @date 2022-01-25 15:51
 */
public class Test {
    static {
        //配置浏览器驱动地址
        System.setProperty("webdriver.edge.driver",
                "C:\\MySoftware\\msedgedriver.exe");
    }
    private  static WebDriver webDriver = new EdgeDriver();

    public static void main(String[] args) throws InterruptedException {

        TimeUnit.SECONDS.sleep(1);
        //打开百度网站
        webDriver.get("https://spms.lpht.com.cn/zjhub/login");
        TimeUnit.SECONDS.sleep(1);
        //输入框输入搜索关键词 selenium 中文官网
        webDriver.findElement(By.name("username")).sendKeys("admin");
        webDriver.findElement(By.name("password")).sendKeys("12345q");
        TimeUnit.SECONDS.sleep(1);
        //点击百度一下按钮
        webDriver.findElement(By.id("btnSubmit")).click();
        TimeUnit.SECONDS.sleep(1);

        webDriver.findElement(By.cssSelector(".dropdown:nth-child(4) > .dropdown-toggle > .hidden-xs")).click();
        webDriver.findElement(By.cssSelector(".mt5:nth-child(2) .hidden-xs:nth-child(2)")).click();
        webDriver.findElement(By.linkText("质检")).click();

        TimeUnit.SECONDS.sleep(1);

        webDriver.findElement(By.linkText("样品管理")).click();

        webDriver.switchTo().frame(1);
        TimeUnit.SECONDS.sleep(1);
        webDriver.findElement(By.cssSelector(".div-bnt:nth-child(1)")).click();
        TimeUnit.SECONDS.sleep(1);
        webDriver.findElement(By.cssSelector(".is-focus > .el-input__inner")).click();
        webDriver.findElement(By.cssSelector(".hover")).click();
        webDriver.findElement(By.cssSelector(".is-focus > .el-input__inner")).click();
        webDriver.findElement(By.cssSelector(".el-select-dropdown:nth-child(6) .el-select-dropdown__item:nth-child(1) > span")).click();
        webDriver.findElement(By.cssSelector(".is-focus > .el-input__inner")).click();
        webDriver.findElement(By.cssSelector(".el-select-dropdown:nth-child(7) .hover")).click();
        TimeUnit.SECONDS.sleep(5);
        //关闭浏览器
        webDriver.quit();
    }
}
